 

package com.zdkj.subway.stm.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.stm.entity.SwStTicketHandDetail;
import com.zdkj.subway.stm.service.SwStTicketHandDetailService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 车票上交明细表
 *
 * @author cuilei
 * @date 2020-05-26 15:04:02
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swsttickethanddetail" )
@Api(value = "swsttickethanddetail", tags = "车票上交明细表管理")
public class SwStTicketHandDetailController {

    private final  SwStTicketHandDetailService swStTicketHandDetailService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param swStTicketHandDetail 车票上交明细表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getSwStTicketHandDetailPage(Page page, SwStTicketHandDetail swStTicketHandDetail) {
        return R.ok(swStTicketHandDetailService.page(page, Wrappers.query(swStTicketHandDetail)));
    }


    /**
     * 通过id查询车票上交明细表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(swStTicketHandDetailService.getById(id));
    }

    /**
     * 新增车票上交明细表
     * @param swStTicketHandDetail 车票上交明细表
     * @return R
     */
    @ApiOperation(value = "新增车票上交明细表", notes = "新增车票上交明细表")
    @SysLog("新增车票上交明细表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('stm_swsttickethanddetail_add')" )
    public R save(@RequestBody SwStTicketHandDetail swStTicketHandDetail) {
        return R.ok(swStTicketHandDetailService.save(swStTicketHandDetail));
    }

    /**
     * 修改车票上交明细表
     * @param swStTicketHandDetail 车票上交明细表
     * @return R
     */
    @ApiOperation(value = "修改车票上交明细表", notes = "修改车票上交明细表")
    @SysLog("修改车票上交明细表" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('stm_swsttickethanddetail_edit')" )
    public R updateById(@RequestBody SwStTicketHandDetail swStTicketHandDetail) {
        return R.ok(swStTicketHandDetailService.updateById(swStTicketHandDetail));
    }

    /**
     * 通过id删除车票上交明细表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除车票上交明细表", notes = "通过id删除车票上交明细表")
    @SysLog("通过id删除车票上交明细表" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('stm_swsttickethanddetail_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(swStTicketHandDetailService.removeById(id));
    }

}
